<?php

namespace Model\Auth;

/**
 * Model which contains the filters and validators for forms of auth module
 */
class filterInput
{
    /**
     * Filter input for register
     * 
     * @return stdClass attributes: filters, validators
     */
    public function register()
    {
        $result = new \stdClass();
        
        $result->filters =
        array('*' => 'StripTags');
        
        $result->validators =
        array(
            'email'     => array('EmailAddress', array('StringLength', 6, 48)),
            'userName'  => array('Alnum', array('StringLength', 2, 32)),
            'name'      => array(array('Alpha', array('allowWhiteSpace' => TRUE)),
                                array('StringLength', 4, 32)),
            'password'  => array('Alnum', array('StringLength', 4, 20)),
            'confirmPassword' =>
                array(
                    array(  'Identical', 
                            array('token' => $_POST['password']))));
        
        return $result;
    }
    
    /**
     * Filter input for login
     * 
     * @return stdClass attributes: filters, validators
     */
    public function login()
    {
        $result = new \stdClass();
        
        $result->filters =
        array('*' => 'StripTags');
        
        $result->validators =
        array(
            'email' => array('EmailAddress', array('StringLength', 6, 48)),
            'password' => array('Alnum', array('StringLength', 4, 20)));
        
        return $result;
    }
}

# eof